﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ylh.Data;
using Ylh.Enums;
using Ylh.ElvModel;
using System.Data;

namespace Ylh.ElvBLL
{
    class CustServerEvlBLL
    {

        public bool InserServer(string ConStr, Ylh.ElvModel.TbCustServer model)
        {
            return TbCustServer.InserObjedct(model, ConStr);
        }

        public bool UpdateServer(string ConStr, Ylh.ElvModel.TbCustServer model)
        {
            return TbCustServer.Update(model, ConStr);
        }

        public bool DeleteServerInfo(string ConStr, int CustServerID)
        {
            TbCustServer Server = new TbCustServer();
            OQLWhere where = new OQLWhere(Server);
            where.AND(Server.CustServerID, OperateType.等于, CustServerID);
            return TbCustServer.Delete(where, ConStr);
        }

        public DataTable SelectServerInfo(string ConStr, int CustID)
        {
            TbCustServer Server = new TbCustServer();
            OQLWhere where = new OQLWhere(Server);
            where.AND(Server.CustID, OperateType.等于, CustID);
            return TbCustServer.Select(where, ConStr);
        }

        public Ylh.ElvModel.TbCustServer GetModel(string ConStr, int CustServerID)
        {
            TbCustServer Server = new TbCustServer();
            OQLWhere where = new OQLWhere(Server);
            where.AND(Server.CustServerID, OperateType.等于, CustServerID);
            DataTable dt = TbCustServer.Select(where, ConStr);
            List<TbCustServer> li = Ylh.Pub.ConverDt2Model.DtToList<TbCustServer>(dt);
            if (li.Count == 0) return new TbCustServer();
            return li[0];
        }
    }
}
